/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * verPostulante.java
 *
 * Created on Jul 27, 2011, 11:43:52 AM
 */
package appescritorio;

import Conexion.AccesoADatos;
import Entidades.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

/**
 *
 * @author martin
 */
public class verPostulante extends javax.swing.JFrame {

    Aviso b;
    int idpostulante;

    /** Creates new form verPostulante */
    public verPostulante() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        lblfecha = new javax.swing.JLabel();
        lblnroDoc = new javax.swing.JLabel();
        lblapellido = new javax.swing.JLabel();
        lbltipodoc = new javax.swing.JLabel();
        lblnombre = new javax.swing.JLabel();
        lblestado = new javax.swing.JLabel();
        lblSexo = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        lblprovincia = new javax.swing.JLabel();
        lbllocalidad = new javax.swing.JLabel();
        lblbarrio = new javax.swing.JLabel();
        lblemail = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        FormAc = new javax.swing.JTextArea();
        jScrollPane2 = new javax.swing.JScrollPane();
        ExpLab = new javax.swing.JTextArea();
        jLabel23 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Información del postulante");
        setMaximizedBounds(new java.awt.Rectangle(0, 0, 500, 600));
        setMinimumSize(new java.awt.Dimension(500, 600));

        jLabel1.setText("Nombre:"); // NOI18N

        jLabel2.setText("Apellido:"); // NOI18N

        jLabel3.setText("Tipo de documento:"); // NOI18N

        jLabel4.setText("Número de documento:"); // NOI18N

        jLabel5.setText("Fecha de nacimiento:"); // NOI18N

        jLabel6.setText("Sexo:"); // NOI18N

        jLabel7.setText("Estado Civil:"); // NOI18N

        lblfecha.setText("jLabel1"); // NOI18N

        lblnroDoc.setText("jLabel1"); // NOI18N

        lblapellido.setText("jLabel1"); // NOI18N

        lbltipodoc.setText("jLabel1"); // NOI18N

        lblnombre.setText("jLabel1"); // NOI18N

        lblestado.setText("jLabel1"); // NOI18N

        lblSexo.setText("jLabel1"); // NOI18N

        jLabel15.setText("Provincia:"); // NOI18N

        jLabel16.setText("E-mail:"); // NOI18N

        jLabel17.setText("Localidad:"); // NOI18N

        jLabel18.setText("Barrio:"); // NOI18N

        lblprovincia.setText("jLabel1"); // NOI18N

        lbllocalidad.setText("jLabel1"); // NOI18N

        lblbarrio.setText("jLabel1"); // NOI18N

        lblemail.setText("jLabel1"); // NOI18N

        FormAc.setColumns(20);
        FormAc.setRows(5);
        jScrollPane1.setViewportView(FormAc);

        ExpLab.setColumns(20);
        ExpLab.setRows(5);
        jScrollPane2.setViewportView(ExpLab);

        jLabel23.setText("Formación académica:"); // NOI18N

        jLabel24.setText("Experiencia laboral:"); // NOI18N

        jButton1.setText("Salir");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel23)
                            .addComponent(jLabel1)
                            .addComponent(jLabel2)
                            .addComponent(jLabel3)
                            .addComponent(jLabel5)
                            .addComponent(jLabel6)
                            .addComponent(jLabel7)
                            .addComponent(jLabel15)
                            .addComponent(jLabel17)
                            .addComponent(jLabel18)
                            .addComponent(jLabel16)
                            .addComponent(jLabel4)
                            .addComponent(jLabel24))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 343, Short.MAX_VALUE)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(lblemail)
                                .addComponent(lbllocalidad)
                                .addComponent(lblbarrio)
                                .addComponent(lblfecha)
                                .addComponent(lblnroDoc)
                                .addComponent(lblapellido)
                                .addComponent(lbltipodoc)
                                .addComponent(lblnombre)
                                .addComponent(lblestado)
                                .addComponent(lblprovincia)
                                .addComponent(lblSexo))
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 343, Short.MAX_VALUE)))
                    .addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblnombre)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblapellido)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbltipodoc)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblnroDoc)
                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblfecha)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblSexo)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblestado)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblprovincia)
                    .addComponent(jLabel15))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbllocalidad)
                    .addComponent(jLabel17))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblbarrio)
                    .addComponent(jLabel18))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblemail)
                    .addComponent(jLabel16))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel23))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton1))
                    .addComponent(jLabel24))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    Inicio i = new Inicio();
    i.setVisible(true);
    this.setVisible(false);
}//GEN-LAST:event_jButton1ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                try {
                    // Set System L&F
                    UIManager.setLookAndFeel(
                            UIManager.getSystemLookAndFeelClassName());
                } catch (UnsupportedLookAndFeelException e) {
                    // handle exception
                } catch (ClassNotFoundException e) {
                    // handle exception
                } catch (InstantiationException e) {
                    // handle exception
                } catch (IllegalAccessException e) {
                    // handle exception
                }
                new verPostulante().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextArea ExpLab;
    private javax.swing.JTextArea FormAc;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel lblSexo;
    private javax.swing.JLabel lblapellido;
    private javax.swing.JLabel lblbarrio;
    private javax.swing.JLabel lblemail;
    private javax.swing.JLabel lblestado;
    private javax.swing.JLabel lblfecha;
    private javax.swing.JLabel lbllocalidad;
    private javax.swing.JLabel lblnombre;
    private javax.swing.JLabel lblnroDoc;
    private javax.swing.JLabel lblprovincia;
    private javax.swing.JLabel lbltipodoc;
    // End of variables declaration//GEN-END:variables

    public void setId(Aviso a, int id) {
        b = a;
        idpostulante = id;
        traerDatos(b, idpostulante);
    }


    /*public void traerPostulantesPorAviso(Aviso aviso,int idpostulante){
    String nombreTipoDoc;
    TipoDoc tipoDoc;
    int nroDoc;
    String nombrePersona="";
    String apellido;
    String estadoCivil;
    String calle;
    String nroCalle;
    String sexo = "";
    Barrio barrio;
    Localidad localidad;
    Provincia provincia;
    String fechaNac;
    String email;
    Usuario usuario;
    int idPostulante;
    Telefono telefono;
    ArrayList<ExperienciaLaboral> experienciaLaboral;
    ArrayList<IdiomaConocido> idiomasConocidos;
    ArrayList<FormacionAcademica> formacionAcademica;
    AccesoADatos con = new AccesoADatos();
    ArrayList postulantes = new ArrayList();
    ResultSet rs = con.leer("select * from persona per, postulante post where post.nombreTipoDoc=per.nombreTipoDoc and post.nroDoc=per.nroTipoDoc post.codAviso=" + aviso.getCodigo() + "and post.seleccionado=0 and post.idPostulante="+idpostulante);
    
    try {
    boolean ban=rs.next();
    while(ban){
    
    nombreTipoDoc = rs.getString("nombreTipoDoc");
    tipoDoc = new TipoDoc(nombreTipoDoc);
    nroDoc = rs.getInt("nroDoc");
    nombrePersona = rs.getString("nombrePersona");
    apellido = rs.getString("apellido");
    estadoCivil = rs.getString("estadoCivil");
    calle = rs.getString("calle");
    nroCalle = rs.getString("nroCalle");
    if (rs.getString("sexo") != null || !rs.getString("sexo").isEmpty()) {
    if (rs.getString("sexo").equalsIgnoreCase("f")) {
    sexo = "Femenino";
    } else if (rs.getString("sexo").equalsIgnoreCase("m")) {
    sexo = "Masculino";
    }
    } else {
    sexo = "No especificado";
    }
    email = rs.getString("email");
    fechaNac = rs.getString("fechaNac");
    idPostulante = rs.getInt("idPostulante");
    Postulante p = new Postulante(apellido, nombrePersona, nroDoc, tipoDoc, estadoCivil, nroCalle, calle, sexo, fechaNac, email, idPostulante, aviso, false);
    //traer y setear los arraylists y usuario
    p.setTelefonos(p.traerTelefonos());
    p.setBarrio(p.traerBarrio());
    p.setExperienciaLaboral(p.traerExperienciasLaborales());
    p.setFormacionAcademica(p.traerFormacionesAcademicas());
    p.setIdiomasConocidos(p.traerIdiomasConocidos());
    p.setUsuario(p.traerUsuario());
    postulantes.add(p);
    ban=rs.next();
    }
    } catch (SQLException ex) {
    }
    jLabel1.setText(nombrePersona);
    
    }*/
    public void traerDatos(Aviso a, int idpostulante) {
        try {
            int idPostulante;
            Telefono telefono;
            String sql1 = "select p.* from persona p,postulante pos where p.nombreTipoDoc=pos.nombreTipoDoc and p.nroDoc=pos.nroDoc and pos.idPostulante=" + idpostulante;

            AccesoADatos acceso = new AccesoADatos();
            ResultSet rs = acceso.leer(sql1);
            rs.next();

            lblnombre.setText(rs.getString("nombrePersona"));
            lbltipodoc.setText(rs.getString("nombreTipoDoc"));
            lblnroDoc.setText(rs.getString("nroDoc"));
            lblapellido.setText(rs.getString("apellido"));
            lblestado.setText(rs.getString("estadoCivil"));
            lblSexo.setText(rs.getString("sexo"));
            lblbarrio.setText(rs.getString("nombreBarrio"));
            lbllocalidad.setText(rs.getString("nombreLocalidad"));
            lblprovincia.setText(rs.getString("nombreProvincia"));
            lblfecha.setText(rs.getString("fechaNac"));
            lblemail.setText(rs.getString("email"));
            String sql2 = "select f.* from formacionacademica f, postulante p where p.`idPostulante`=f.`idPostulante` and p.`idPostulante`=" + idpostulante;
            rs = acceso.leer(sql2);
            while (rs.next()) {
                FormAc.append("Nombre Institucion: " + rs.getString("nombreInstitucion") + "\n" + "Tipo Institucion: " + rs.getString("nombreTipoInstitucion") + "\n Provincia: " + rs.getString("nombreProvincia") + "\n Localidad: " + rs.getString("nombreLocalidad") + "\n Titulo: " + rs.getString("titulo") + "\n Tipo de Titulo: " + rs.getString("nombreTipoTitulo") + "\n Fecha Finalizacion: " + rs.getString("fechaFinalizacion") + "\n\n");
            }
            String sql3 = "select exp.* from experiencialaboral exp, postulante p where exp.`idPostulante`=p.`idPostulante` and p.`idPostulante`=" + idpostulante;
            rs = acceso.leer(sql3);
            while (rs.next()) {
                ExpLab.append("Nombre Empresa: " + rs.getString("nombreEmpresa") + "\nNombre del supervisor: " + rs.getString("nombreSupervisor") + "\nDesde: " + rs.getString("fechaDesde") + "\nHasta: " + rs.getString("fechaHasta"));

            }


        } catch (SQLException ex) {
            Logger.getLogger(verPostulante.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
}
